<template>
    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.id">
                <router-link :to="'/home/newsinfo/'+item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        <h1>{{item.title}}</h1>
                        <p class='mui-ellipsis'>
                            <span>发表时间:{{item.add_time | dataFormat}}</span>
                            <span>点击:{{item.click}}次</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>

    import { Toast } from "mint-ui";

    export default{
        data(){
            return {
                newsList : []
            }
        },
        created(){
            this.getNewslist();
        },
        methods : {
            getNewslist(){
                /* this.$http.get('').then(result => {
                    console.log(result.body);
                    if(result.body.status === 0){
                        this.newsList = result.body.message;
                    }else{
                        Toast('加载新闻列表失败。。。')
                    }
                }) */

                this.newsList = [
                    {"id":1,"title":"不上班真好","add_time":"2019-10-11 12:53:43","zhaiyao":"不上班","click":12,"img_url":"/src/images/1.jpg"},
                    {"id":2,"title":"但是只入不出","add_time":"2019-10-11 12:53:43","zhaiyao":"只花钱","click":12,"img_url":"/src/images/2.jpg"},
                    {"id":3,"title":"也不是很合适吧","add_time":"2019-10-11 12:53:43","zhaiyao":"不赚钱","click":12,"img_url":"/src/images/1.jpg"},
                    {"id":4,"title":"想想自己有房有车了吗","add_time":"2019-10-11 12:53:43","zhaiyao":"没资本","click":12,"img_url":"/src/images/3.jpeg"},
                    {"id":5,"title":"赶紧爬起来去找工作吧","add_time":"2019-10-11 12:53:43","zhaiyao":"滚去找工作","click":12,"img_url":"/src/images/2.jpg"},
                    {"id":6,"title":"但是只入不出","add_time":"2019-10-11 12:53:43","zhaiyao":"只花钱","click":12,"img_url":"/src/images/2.jpg"},
                    {"id":7,"title":"也不是很合适吧","add_time":"2019-10-11 12:53:43","zhaiyao":"不赚钱","click":12,"img_url":"/src/images/1.jpg"},
                    {"id":8,"title":"想想自己有房有车了吗","add_time":"2019-10-11 12:53:43","zhaiyao":"没资本","click":12,"img_url":"/src/images/3.jpeg"},
                    {"id":9,"title":"赶紧爬起来去找工作吧","add_time":"2019-10-11 12:53:43","zhaiyao":"滚去找工作","click":12,"img_url":"/src/images/2.jpg"},
                    {"id":10,"title":"但是只入不出","add_time":"2019-10-11 12:53:43","zhaiyao":"只花钱","click":12,"img_url":"/src/images/2.jpg"},
                    {"id":11,"title":"也不是很合适吧","add_time":"2019-10-11 12:53:43","zhaiyao":"不赚钱","click":12,"img_url":"/src/images/1.jpg"},
                    {"id":12,"title":"想想自己有房有车了吗","add_time":"2019-10-11 12:53:43","zhaiyao":"没资本","click":12,"img_url":"/src/images/3.jpeg"},
                    {"id":13,"title":"赶紧爬起来去找工作吧","add_time":"2019-10-11 12:53:43","zhaiyao":"滚去找工作","click":12,"img_url":"/src/images/2.jpg"}
                    ]
            }
        }
    }
</script>

<style lang="scss" scoped>
    .mui-table-view{
        li{
            h1{
                font-size: 14px;
            }
            .mui-ellipsis{
                font-size: 12px;
                color: #226aff;
                display: flex;
                justify-content: space-between;
            }
        }
    }
</style>